import store from '../store';

const directives = {
    auth: {
        mounted(el, binding) {
            const useAuth = store.useAuthStore();
            const permissions = useAuth.permissions;
            const code = binding.value;
            if (!permissions.has(code)) {
                el?.parentNode?.removeChild(el);
            }
        }
    }
};

export default app => {
    Object.keys(directives).forEach(item => {
        app.directive(item, directives[item]);
    });
};
